package com.cloudbroker.bcs.platform.dav.middle.service.base;

import org.springframework.context.annotation.Scope;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

import com.cloudbroker.bcs.common.entity.Pageable;
import com.cloudbroker.bcs.platform.dav.middle.dao.base.TenantDAOBase;

@Service
@Scope("prototype")
public class AsyncServiceImpl<T extends Pageable, K> implements AsyncService<T, K> {
    
    private TenantDAOBase<T, K> dao;
    
    public void setDAO(TenantDAOBase<T, K> dao) {
        this.dao = dao;
    }
    
    @Async
    public synchronized void update(T entity) {
        this.dao.update(entity);
    }
    
    @Async
    public void delete(K key, Integer tenantId) {
        this.dao.delete(key, tenantId);
    }
}
